/********************************************************/
/*	Author:		gong_libin			*/
/*	Date:		2014_10_21			*/
/*	File:		GtRmShm.c			*/
/********************************************************/

#include "GtRmUtil.h"

int main(int argc, char* argv[])
{
	int iShm = 0;
	GTRUSHM_S* pstCur = NULL;
	GTRUSHM_S* pstShm = NULL;

	if (GT_FAILURE != (iShm = shmget(ftok(GT_RU_PATH, GT_RU_KEY), sizeof(GTRUSHM_S) * GT_RU_TTL, IPC_CREAT | 0777))) {
		if (NULL != (pstCur = pstShm = (GTRUSHM_S*)shmat(iShm, NULL, 0))) {
			while (pstCur - pstShm < GT_RU_TTL) {
				GT_PRINT("Index[%02d]: ", (int)(pstCur - pstShm));
				GT_PRINT("Recv = %llu\tBytes = %llu\t", pstCur->m_ullRecv, pstCur->m_ullBytes);
				GT_PRINT("Send = %llu\tLose = %llu\n", pstCur->m_ullSend, pstCur->m_ullRecv - pstCur->m_ullSend);
				pstCur += 1;
			}
		}
		else {
			GT_ERROR("%s\n", strerror(errno));
		}
	}
	else {
		GT_ERROR("%s\n", strerror(errno));
	}

	return GT_SUCCESS;
}
